﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using CommunitySystem.JinShengService;
using System.Collections.ObjectModel;

namespace CommunitySystem.PageView.晋升管理.新的晋升管理
{
    public partial class JSControl2 : UserControl
    {
        private JinShengService.JinShengServiceClient _client = null;
        private JinShengService.JinShen_ChooseCandidator_Main chooseMain = null;
        private JinShengService.JinShen_MainInfo _mainInfo = null;
        private ObservableCollection<JinShengService.JinShen_KaoCha_Detail> details = new ObservableCollection<JinShengService.JinShen_KaoCha_Detail>();


        public JSControl2(JinShen_MainInfo mainInfo, ObservableCollection<JinShengService.JinShen_KaoCha_Detail> _details)
        {
            InitializeComponent();
            _mainInfo = mainInfo;
          //  details.Clear();
            details = _details;
          
            LoadUI();
        }
    
        private bool CanEditInfo = true;
   
        private void LoadUI()
        {
            detailsInfo.Children.Clear();
            var des = details.Where(p => p.MainID == _mainInfo.ID).ToList();
            if (des != null && des.Count > 0)
            {
                TextBlock tb = new TextBlock() { Text = "科室:" + _mainInfo.Department, Margin = new Thickness(10, 0, 0, 0), VerticalAlignment = System.Windows.VerticalAlignment.Center };
                selectionInfo.Children.Add(tb);
                tb = new TextBlock() { Text = "职位:" + _mainInfo.Position + "(" + _mainInfo.PositionLevel + ")", Margin = new Thickness(60, 0, 0, 0), VerticalAlignment = System.Windows.VerticalAlignment.Center };
                selectionInfo.Children.Add(tb);

                foreach (var d in des)
                {
                    StackPanel sp = new StackPanel() { Orientation = Orientation.Horizontal, Margin = new Thickness(3) };
                    tb = new TextBlock() { Text = d.EmpName, Width = 40, TextAlignment = TextAlignment.Right, HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Center };
                    TextBox tBox = new TextBox() { Height = 40, Width = 600, Margin = new Thickness(6, 0, 0, 0), TextWrapping = TextWrapping.Wrap,AcceptsReturn=true };
                    tBox.IsReadOnly = !CanEditInfo;
                    tBox.SetBinding(TextBox.TextProperty, new System.Windows.Data.Binding("DSC") { Mode = System.Windows.Data.BindingMode.TwoWay });
                    tBox.DataContext = d;
                    sp.Children.Add(tb);
                    sp.Children.Add(tBox);
                    detailsInfo.Children.Add(sp);
                }
            }
            else
                LayoutRoot.Visibility = Visibility.Collapsed;

        }

      
    }
}
